Ensure a property is reflect to attribute when it is changed after an attribute change #596
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #592
The update method is responsible to reflect property changes to attributes. Changing a property that has reflect equals true will populate the _reflectingProperties to indicate that the changed property must be reflected to its attribute.
There is a logic that prevents the property being changed from being added to the _reflectingProperties, if the property change was caused by an attribute change.
There is also the _changedProperties map that contains the keys for any properties that have changed since the last update cycle.
If the the same property is changed multiple times on the same update cycle, of course its key is added just once _changedProperties map.
The problem occurs when you change an attribute and on the sae update cycle change the property. In this scenario, when you change the attribute then the property is not added to the _reflectingProperties map. iI after changing the attribute, you change the property then the property is already on the _changedProperties map and the logic that adds the property to the _reflectingProperties is not executed in this case.
This leads to the update method to not reflect the property change to the attribute.
I changed the updating-element.ts code to add to the _reflectingProperties map when the property is changed, even if the property is already on the _changedProperties map. Also if the property change come from an attribute change I remove the property from the _reflectingProperties map.